import cv2
import os


class HeartRate():
    UPLOAD_FOLDER = 'tmp/uploads'  # 文件下载路径

    file_name = None

    def __init__(self, filename):
        self.file_name = filename

    def parse(self):
        cap = cv2.VideoCapture(os.path.join(self.UPLOAD_FOLDER, self.file_name))
        # 调用cv2方法获取cap的视频帧（帧：每秒多少张图片）
        fps = cap.get(cv2.CAP_PROP_FPS)
        print(fps)
        # 获取cap视频流的每帧大小
        size = (int(cap.get(cv2.CAP_PROP_FRAME_WIDTH)), int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT)))
        print(size)
